package com.gaofei.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author : gaofee
 * @date : 9:49 2021/6/24
 * @码云地址 : https://gitee.com/itgaofee
 */
@Component
public class BizConsumer {

    @RabbitListener(queues = "bizQueue1")
    public void receiveBizMsg1(Message message, Channel channel) throws IOException {
        System.out.println("收到消息1：" + new String(message.getBody()));
        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }


    @RabbitListener(queues = "bizQueue2")
    public void receiveBizMsg2(Message message, Channel channel) throws IOException {
        System.out.println("收到消息2：" + new String(message.getBody()));
        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
